/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	RasterizerStage.h
*
*	Description -	
*
*	Comments	-	
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	10/11/2012	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_RASTERIZER_STAGE_H_
#define _PSX_RASTERIZER_STAGE_H_

#include "PulseSTD.h"
//#include "GraphicsInfrastructure.h
#include "IPipelineStage.h"
#include "Viewport.h"
#include "2D.h"

namespace Pulse
{
	struct RasterizerStageState
	{
		void Clear( void );

		RasterizerState		*m_pState;
		Viewport			m_viewport;
		Rect				m_scissorRect;
	};

	class RasterizerStage : public IPipelineStage
	{
	public:

		RasterizerStage( void );

		virtual ~RasterizerStage( void );

		virtual EPipelineStage::Type GetType( void ) { return EPipelineStage::Rasterizer; }
	
		void SetRasterizerState( RasterizerState *pState );

		void SetScissorRect(  Rect *pRect  );

		void SetViewport( Viewport *pViewport );

		virtual void ClearStates( void );

		// Binding methods

		void BindRasterizerState( void );

		void BindScissorRect( void );

		void BindViewport( void );

		// Calls all the binding methods above
		virtual void BindStates( void );
	
	private:

		RasterizerStageState m_currentState;
		RasterizerStageState m_desiredState;

		BOOL m_bUpdateRasterState;
		BOOL m_bUpdateViewport;
		BOOL m_bUpdateScissorRect;
	};

	PSX_INLINE void RasterizerStage::BindStates( void )
	{
		BindRasterizerState();
		BindScissorRect();
		BindViewport();
	}
	 
}

#endif /* _PSX_RASTERIZER_STAGE_H_ */